package com.schoolvisitors.vo;

import com.schoolvisitors.entity.Floor;
import com.schoolvisitors.entity.Instrument;
import com.schoolvisitors.entity.InstrumentLoan;
import com.schoolvisitors.entity.Room;
import com.schoolvisitors.enums.InstrumentLoanType;
import lombok.Data;

import java.time.LocalDateTime;
@Data
public class InstrumentLoanToUserVo {
    private Long id;
    private String instrumentName;
    private String status;
    private LocalDateTime borrowTime;
    private LocalDateTime returnTime;
    private String remark;
    private String realName;
    private String currentLocation;
    private String floorName;
    private String roomSubType;
    private Long roomNumber;
   // private
//    private Room instrumentRoom;
//    private Room borrowedRoom;

    public static InstrumentLoanToUserVo from(InstrumentLoan loan) {
        InstrumentLoanToUserVo vo = new InstrumentLoanToUserVo();
        vo.id = loan.getId();
        if (loan.getType() == InstrumentLoanType.LIST){
            vo.instrumentName = loan.getInstrument().getName();
        }
        Instrument instrument = loan.getInstrument();
        //Room room = instrument.getRoom();
//        vo.instrumentRoom = instrument.getRoom();
//        vo.borrowedRoom = loan.getBorrowRoom();
//        Floor floor = room.getFloor();
//        vo.floorName = floor.getName();
//        vo.roomSubType = room.getSubType();
//        vo.roomNumber = room.getNumber();

//        vo.currentLocation =
        vo.status = loan.getStatus().toString();
        vo.borrowTime = loan.getBorrowTime();
        vo.returnTime = loan.getReturnTime();
        vo.remark = loan.getRemark();
        vo.realName = loan.getUser().getRealName();
        return vo;
    }
}